<template>
  <div>
    <el-button @click="downloadTemplate()" size="small" type="primary">导入模板下载</el-button>
    <div style="margin:20px 0"></div>
    <importFile
      :title="'导入'"
      :actionUrl="urls"
      @close="closeHandler"
    />

    <div style="height:47px;"></div>
  </div>
</template>
<script>
import { exportTemplateFile } from '@/api/omSaleP/FileDownloadTemplate';
import {exportExcelFile} from '@/utils';
import config from '@/assets/js/config.js'
import SERVER from '@/api/server';

export default {
  data() {
    return {
      urls: config.uploadUrl + `${SERVER.WHOLESALES}/orderManage/orderImport`,
      fetchParams: {},
      fetchApi: () => {
      },
    }
  },
  methods: {
    downloadTemplate() {
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
        confirmButtonText: '下载',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.exportLoading = true;
        exportTemplateFile({'fileName':'Order_Import.xls'})
          .then(response => {
            exportExcelFile(response.data, '总部订单导入模板');
            this.exportLoading = false;
          })
          .catch(err => {
            //console.log(err);
          });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    closeHandler(val) {
      this.$emit('close');
    },
  },
}

</script>
